using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Net;

namespace TMM
{
    public class InternetBroadcastReceiver : BroadcastReceiver
    {
        public BaseActivity BaseActivity { get; private set; }
        public InternetBroadcastReceiver(BaseActivity activity)
        {
            BaseActivity = activity;
        }

        public override void OnReceive(Context context, Intent intent)
        {
            var noConnectivity = intent.GetBooleanExtra(ConnectivityManager.ExtraNoConnectivity, false);
            String reason = intent.GetStringExtra(ConnectivityManager.ExtraReason);
            var isFailover = intent.GetBooleanExtra(ConnectivityManager.ExtraIsFailover, false);

            NetworkInfo currentNetworkInfo = (NetworkInfo)intent.GetParcelableExtra(ConnectivityManager.ExtraNetworkInfo);

            if (!currentNetworkInfo.IsConnected)
                BaseActivity.OnNoInternetAccess();
        }
    }
}